package com.lanling.customerconsumer.feign.factory;

import com.lanling.customerconsumer.feign.UserFeignFallBack;
import com.lanling.customerconsumer.service.UserFeignClient;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignFallBackFactory implements FallbackFactory<UserFeignClient> {

    private final UserFeignFallBack userFeignFallback;

    public UserFeignFallBackFactory(UserFeignFallBack userFeignFallback) {
        this.userFeignFallback = userFeignFallback;
    }

    @Override
    public UserFeignClient create(Throwable cause) {
        cause.printStackTrace();
        return userFeignFallback;
    }
}
